import http from '@/utils/http'

const BASE_URL = '/system/officeBuilding'

export interface OfficeBuildingResp {
  id: string
  name: string
  factorySiteId: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface OfficeBuildingDetailResp {
  id: string
  name: string
  factorySiteId: string
  factorySiteName: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface OfficeBuildingQuery {
  name: string
  sort: Array<string>
}
export interface OfficeBuildingPageQuery extends OfficeBuildingQuery, PageQuery {}

/** @desc 查询厂区办公楼列表 */
export function listOfficeBuilding(query: OfficeBuildingPageQuery) {
  return http.get<PageRes<OfficeBuildingResp[]>>(`${BASE_URL}/getFactorySite`, query)
}

/** @desc 查询厂区办公楼详情 */
export function getOfficeBuilding(id: string) {
  return http.get<OfficeBuildingDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增厂区办公楼 */
export function addOfficeBuilding(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改厂区办公楼 */
export function updateOfficeBuilding(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除厂区办公楼 */
export function deleteOfficeBuilding(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出厂区办公楼 */
export function exportOfficeBuilding(query: OfficeBuildingQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
